import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/cities',
    name: 'Cities',
    component: () => import('@/views/Cities.vue')
  },
  {
    path: '/city/:id',
    name: 'CityDetail',
    component: () => import('@/views/CityDetail.vue'),
    props: true
  },
  {
    path: '/food',
    name: 'Food',
    component: () => import('@/views/Food.vue')
  },
  {
    path: '/travel-guide',
    name: 'TravelGuide',
    component: () => import('@/views/TravelGuide.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue')
  },
  {
    path: '/profile',
    name: 'Profile',
    component: () => import('@/views/Profile.vue')
  },
  {
    path: '/search',
    name: 'SearchResults',
    component: () => import('@/views/SearchResults.vue')
  }
]

const router = createRouter({
  history: createWebHistory('/'),
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  }
})

export default router